<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="../../css/api.css">
    <link rel="stylesheet" href="../../css/news.css">
    <style>
        html,
        body {
            background: transparent;
        }

        body {
            margin: 0;
        }

        .modal {
            /* background-color: rgba(0, 0, 0, 0.2); */
            position: absolute;
            top: 0;
            left: 0;
            width: 100vw;
            height: 100vh;
        }

        .main {
            width: 80vw;
            border-radius: 14px;
            background-color: #fff;
            position: absolute;
            left: 10vw;
            top: 40vw;
        }

        .box {
            width: 80vw;
            background: linear-gradient(0deg, rgba(244, 108, 239, 0), rgba(244, 108, 239, 0.16));
            border-radius: 14px;
            padding: 24px 20px;
            box-sizing: border-box;
        }

        .box .title {
            font-size: 20px;
            font-weight: bold;
            text-align: center;
            color: #323232;
            margin-bottom: 24px;
        }

        .box .label {
            color: #A3A3A3;
            font-size: 14px;
        }

        .box textarea {
            background: #F1F1F1;
            border: none;
            outline: none;
            border-radius: 10px;
            resize: none;
            padding: 12px 14px;
            width: 100%;
            box-sizing: border-box;
            margin: 16px 0;
            height: 50vw;
        }

        .box textarea::placeholder {
            color: #999;
        }

        .box .btn {
            background: #F46CEF;
            border-radius: 57px;
            padding: 10px 0;
            color: #fff;
            text-align: center;
        }
    </style>
</head>

<body>
    <div class="modal" id='view' @click="close">
        <div class="main" @click.stop>
            <div class="box">
                <div class="title">文字招呼</div>
                <div class="label">输入你认为具备吸引力的话：</div>
                <textarea v-model="text" placeholder="如：你也是来这里找对象的么?"></textarea>
                <div class="btn" @click="submit">确定</div>
            </div>
        </div>
    </div>
    <script src="../../script/api.js"></script>
    <script src="../../script/jquery.js"></script>
    <script src="../../script/vue.js"></script>
    <script src="../../script/ffkj.js"></script>
    <script>
        var view = new Vue({
            el: '#view',
            data: {
                text: '',
                id: '',
            },
            methods: {
                close() {
                    api.closeFrame({
                        name: 'frame3/text_modify_modal'
                    })
                },
                submit() {
                    if (!$.trim(view.text)) {
                        _msg('请输入内容');
                        return;
                    }
                    var obj = {
                        user_id: $api.getStorage('userid'),
                        channel: 2,
                        content: view.text
                    }
                    if (view.id) {
                        obj.id = view.id;
                    }
                    _ajax('api/privatechat/addCommonWords', function (ret, err) {
                        _msg(ret.msg);
                        if (ret && ret.code == 200) {
                            api.execScript({
                                frameName: 'frame3/modify_frame',
                                script: 'getData();'
                            })
                            setTimeout(function(){
                                view.close();
                            }, 1000)
                        }
                    }, obj)
                }
            }
        })

        apiready = function () {
            view.id = api.pageParam['id'];
            view.text = api.pageParam['content'];
        }
    </script>
</body>

</html>